var vectors, map;

var styles = new OpenLayers.StyleMap({
		 "default": new OpenLayers.Style(null, {
				 rules: [
						 new OpenLayers.Rule({
								 symbolizer: {
										 "Point": {
												 pointRadius: 5,
												 graphicName: "square",
												 fillColor: "white",
												 fillOpacity: 0.25,
												 strokeWidth: 1,
												 strokeOpacity: 1,
												 strokeColor: "#333333"
										 },
										 "Line": {
												 strokeWidth: 3,
												 strokeOpacity: 1,
												 //strokeColor: "#666666"
												strokeColor: "#FF0000"
										 }
								 }
						 })
				 ]
		 }),
		 "select": new OpenLayers.Style({
				 strokeColor: "#00ccff",
				 strokeWidth: 4
		 }),
		 "temporary": new OpenLayers.Style(null, {
				 rules: [
						 new OpenLayers.Rule({
								 symbolizer: {
										 "Point": {
												 pointRadius: 5,
												 graphicName: "square",
												 fillColor: "white",
												 fillOpacity: 0.25,
												 strokeWidth: 1,
												 strokeOpacity: 1,
												 strokeColor: "#333333"
										 },
										 "Line": {
												 strokeWidth: 3,
												 strokeOpacity: 1,
												 strokeColor: "#00ccff"
										 }
								 }
						 })
				 ]
		 })
});

var inform = function(ygid) {
	var pars={ygid:ygid};

	new Ajax.Request("/mobile/get_user_points", { 
		method: "POST",
		parameters: pars,
		onComplete:	 function(request) {
			var users = eval("("+request.responseText+")");
			var pointList = []; 

			for (var i = users.length - 1; i >= 0; i--){
				var loc = users[i].users;
				var pts = loc.lon_lat.split(" ");
				var x0 = parseFloat(pts[0]);
				var y0 = parseFloat(pts[1]);
				
				var point = new OpenLayers.Geometry.Point(x0, y0);
				pointList.push(point);		
			}; //end of for

			if (users.length > 0) {
				var loc = users[0].users;
				
				var pt = users[parseInt(users.length/2)].users.lon_lat.split(" ");
				map.setCenter(new OpenLayers.LonLat(parseFloat(pt[0]),parseFloat(pt[1])), 14);

				var linearRing = new OpenLayers.Geometry.LineString(pointList);

				style_line = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default','select']);
				style_line.fillColor = 'bule';
				style_line.strokeColor = 'blue';
				style_line.strokeWidth = 3;

				style_line.fontSize	 = "12px";
				style_line.fontFamily = "Courier New, monospace";
				style_line.fontWeight = "bold";
				style_line.labelAlign = "rb";						
				style_line.label = loc.ygid;
				style_line.fontColor = "blue"; 

				var lineFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.MultiLineString([linearRing]), {fid: loc.ygid}, style_line);
				vectors.addFeatures([lineFeature]);
				
			}; //end if
		} //end of onComplete
	});

}; 

